package com.sikuli.appmanager;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;

import com.sikuli.common.TestBase;

public class StartHydra {
	protected static final Integer waitTime = 30;
	protected static StartHydra app;
	public static Process p;
	public static String commonFolder = "C:/Users/alexey_morozov/Eclipse_projects/Hydra/inputScreens/Common_folder";
	
	public static  StartHydra getInstance(String sikuli)
			throws Exception, IOException, AWTException, FindFailed  {
		app=null;
		if (app == null) {
			p  = Runtime.getRuntime().exec("C:\\Users\\alexey_morozov\\Downloads\\Hydra\\Hydra_Application.exe");			
			Screen screen = new Screen();
			File commonFolder = new File(StartHydra.commonFolder);
			String path = commonFolder.getAbsolutePath(); 
						
			Pattern openFile = new Pattern(path + "//File.PNG");
			openFile.similar((float)0.99);
			screen.wait(openFile);
			screen.click(openFile, 0);	
			}				
			return app;
		}
	
	
	public static String getCommonFolder () {		
			File commonFolder = new File(StartHydra.commonFolder);
			String path = commonFolder.getAbsolutePath();
			return path; 						
			}	
	}



	

